package com.weipai.springboot.module.dao.impl;

import com.weipai.springboot.model.GoodsPrice;
import com.weipai.springboot.module.dao.GoodsPriceDao;
import com.weipai.springboot.module.mapper.GoodsPriceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Author: 曹朋飞
 * @Date: 2018/08/24 16:45
 */
@Repository
public class GoodsPriceDaoImpl implements GoodsPriceDao {

    @Autowired
    GoodsPriceMapper goodsPriceMapper;

    //查出商品的各种级别对应的价格
    @Override
    public List<GoodsPrice> getListByGoodsId(String goodsId) {
        return goodsPriceMapper.getListByGoodsId(goodsId);
    }

    //查询商品的价格
    @Override
    public Map<String, Object> getGoodsPriceByGoodsId(String goodsId, String customerId) {
        return goodsPriceMapper.getGoodsPriceByGoodsId(goodsId, customerId);
    }

    @Override
    public int updateByPrimaryKeySelective(GoodsPrice goodsPrice) {
        return goodsPriceMapper.updateByPrimaryKeySelective(goodsPrice);
    }

    @Override
    public void save(List<GoodsPrice> goodsPrices) {
        int size01 = goodsPrices.size();
        for(int i=0;i<size01;i++){
            goodsPriceMapper.insert(goodsPrices.get(i));
        }
    }

    @Override
    public GoodsPrice getGoodsPriceByGoodsIdAndMemberLevelId(String goodsId, String memberLevelId) {
        return goodsPriceMapper.getGoodsPriceByGoodsIdAndMemberLevelId(goodsId, memberLevelId);
    }

    @Override
    public int insert(GoodsPrice goodsPrice) {
        return goodsPriceMapper.insert(goodsPrice);
    }
}
